<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //父类
        class Father {
            //构造函数
            constructor(x, y) {
                this.x = x;
                this.y = y;
            }
            //方法
            sum() {
                console.log(this.x + this.y);
            }
        }
        //子类继承父类
        class Son extends Father {
            constructor(x, y) {
                super(x, y); //通过super关键字可以调用父类的构造函数
            }
        }
        //创建子类对象
        var son = new Son(1, 2);
        son.sum();
    </script>
</body>

</html>